package com.ruoyi.web.controller.tongban;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.tongban.domain.InsClassCamera;
import com.ruoyi.tongban.service.IInsClassCameraService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 班级-监控视频关系Controller
 * 
 * @author caiyanshan
 * @date 2021-03-09
 */
@RestController
@RequestMapping("/tongban/classCamera")
public class InsClassCameraController extends BaseController
{
    @Autowired
    private IInsClassCameraService insClassCameraService;

    /**
     * 查询班级-监控视频关系列表
     */
    @PreAuthorize("@ss.hasPermi('tongban:classCamera:list')")
    @GetMapping("/list")
    public TableDataInfo list(InsClassCamera insClassCamera)
    {
        startPage();
        List<InsClassCamera> list = insClassCameraService.selectInsClassCameraList(insClassCamera);
        return getDataTable(list);
    }

    /**
     * 导出班级-监控视频关系列表
     */
    @PreAuthorize("@ss.hasPermi('tongban:classCamera:export')")
    @Log(title = "班级-监控视频关系", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(InsClassCamera insClassCamera)
    {
        List<InsClassCamera> list = insClassCameraService.selectInsClassCameraList(insClassCamera);
        ExcelUtil<InsClassCamera> util = new ExcelUtil<InsClassCamera>(InsClassCamera.class);
        return util.exportExcel(list, "classCamera");
    }

    /**
     * 获取班级-监控视频关系详细信息
     */
    @PreAuthorize("@ss.hasPermi('tongban:classCamera:query')")
    @GetMapping(value = "/{classCameraId}")
    public AjaxResult getInfo(@PathVariable("classCameraId") Long classCameraId)
    {
        return AjaxResult.success(insClassCameraService.selectInsClassCameraById(classCameraId));
    }

    /**
     * 新增班级-监控视频关系
     */
    @PreAuthorize("@ss.hasPermi('tongban:classCamera:add')")
    @Log(title = "班级-监控视频关系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InsClassCamera insClassCamera)
    {
        return toAjax(insClassCameraService.insertInsClassCamera(insClassCamera));
    }

    /**
     * 修改班级-监控视频关系
     */
    @PreAuthorize("@ss.hasPermi('tongban:classCamera:edit')")
    @Log(title = "班级-监控视频关系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InsClassCamera insClassCamera)
    {
        return toAjax(insClassCameraService.updateInsClassCamera(insClassCamera));
    }

    /**
     * 删除班级-监控视频关系
     */
    @PreAuthorize("@ss.hasPermi('tongban:classCamera:remove')")
    @Log(title = "班级-监控视频关系", businessType = BusinessType.DELETE)
	@DeleteMapping("/{classCameraIds}")
    public AjaxResult remove(@PathVariable Long[] classCameraIds)
    {
        return toAjax(insClassCameraService.deleteInsClassCameraByIds(classCameraIds));
    }
}
